<?php

namespace api\common\controllers;

use yii\web\Controller;
use yii\filters\AccessControl;

/**
 * Site controller
 */
class SiteController extends Controller
{
    /**
     * {@inheritdoc}
     */
    public function behaviors ()
    {
        return [
            'access' => [
                'class'        => AccessControl::className() ,
                'rules'        => [
                    [
                        'allow' => FALSE ,
                        'roles' => [ '@' , '?' ] ,
                    ] ,
                ] ,
                'denyCallback' => function ( $rule , $action ) {
                    echo 'You are not allowed to access this page';
                } ,
            ] ,
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function actions ()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction' ,
            ] ,
        ];
    }

    /**
     * Displays homepage.
     *
     * @return string
     */
    public function actionIndex ()
    {
        return $this->render( 'index' );
    }
}
